package com.geeka.d08;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TestException {
    public static void main(String[] args) throws ArrayIndexOutOfBoundsException {
        /**
         * 常见异常
         */
        int[] arr = {3, 2, 4, 5};
//        System.out.println(arr[9]);
        List<String> list = new ArrayList<>();
//        list.get(0);

        String str = "9.9gg";
//        Double.parseDouble(str);

        String strDate = "2023-09-09日 12:00:00";
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd日 HH:mm:ss");
        LocalDateTime localDateTime = LocalDateTime.parse(strDate, dtf);
//        System.out.println(localDateTime);

        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd日 HH:mm:ss");
        System.out.println(sdf.format(date));
//        System.out.println(date);

//        String myStr = null;
//        // NullPointerException
//        System.out.println(myStr.length());

        Animal a1 = new Cat();
        Animal a2 = new Tiger();
//        ClassCastException
//        Tiger a11= (Tiger)a1;

        String date2 = "2023-09-09日 12:00:00";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date d = sdf2.parse(date2);
            System.out.println(d);
        } catch (ParseException e) {
//            e.printStackTrace();
            System.out.println("go on");
        }


    }
}
